<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>X路号码</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../../js/element-ui-2.13.0/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../../styles/common.css"/>
    <link rel="stylesheet" href="../../styles/index.css"/>
    <link rel="stylesheet" href="../../styles/icon/iconfont.css"/>
    <link rel="stylesheet" href="../../styles/pages.css"/>
</head>
<body>
<div class="dashboard-container" id="category-app">
    <div class="container">
        <div
                class="tableBar"
                style="display: inline-block"
        >
            <el-input
                    v-model="number"
                    placeholder="请输入号码"
                    style="width: 250px"
                    clearable
                    @input="handleQuery"
            >
            </el-input>
            <el-select v-model="endId" filterable placeholder="请选择对接网关" @change="handleQuery" clearable>
                <el-option
                        v-for="item in endList"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                </el-option>
            </el-select>
        </div>
        <el-table
                :data="tableData"
                stripe
                class="tableBox"
                @sort-change="handleSortChange"
        >
            <el-table-column
                    prop="number"
                    label="号码"
                    sortable="true"
            />
            </el-table-column>
            <el-table-column
                    prop="company"
                    label="公司名"
            />
            </el-table-column>
        </el-table>
        <el-pagination
                class="pageList"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="counts"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
        ></el-pagination>
    </div>
</div>
<script src="../../js/vue.js"></script>
<script src="../../js/element-ui-2.13.0/lib/index.js"></script>
<script src="../../js/axios-0.18.0.js"></script>
<script src="../../js/request.js"></script>
<script src="../../js/query.js"></script>
<script>
    new Vue({
        el: '#category-app',
        data() {
            return {
                action: '',
                counts: 0,
                pageNum: 1,
                pageSize: 10,
                tableData: [],
                orderByColumn: '',
                isAsc: '',
                type: '',
                number: '',
                numbers: '',
                frontId: '',
                endId: '',
                endList: [],
                numberParams: {
                    'dialogVisible': false,
                    'number': '',
                    'id': '',
                    'company': ''
                }
            }
        },
        computed: {},
        created() {
            if (localStorage.getItem("endId") != null && localStorage.getItem("endId") != '') {
                this.endId = parseInt(localStorage.getItem("endId"));
            }
            this.init();
            window.localStorage.clear();
        },
        mounted() {
        },
        methods: {
            async init() {
                this.endList = []
                await queryEndProperty({}).then(res => {
                    res.result.forEach(item => {
                        let arr = {
                            value: item.id,
                            label: item.end
                        };
                        this.endList.push(arr);
                    });
                }).catch(err => {
                    this.$message.error('请求出错了：' + err)
                });
                await queryAllXNumber({
                    'pageNum': this.pageNum,
                    'pageSize': this.pageSize,
                    'number': this.number,
                    'id': this.endId,
                    'orderByColumn': this.orderByColumn,
                    'isAsc': this.isAsc
                }).then(res => {
                    if (String(res.code) == 200) {
                        this.tableData = res.result.data
                        this.counts = Number(res.result.total)
                    } else {
                        this.$message.error(res.msg || '操作失败')
                    }
                }).catch(err => {
                    this.$message.error('请求出错了：' + err)
                });
            },
            handleQuery() {
                this.pageNum = 1;
                this.init();
            },
            //切换页面大小
            handleSizeChange(val) {
                this.pageSize = val
                this.init()
            },
            //换页
            handleCurrentChange(val) {
                this.pageNum = val
                this.init()
            },
            //排序
            handleSortChange(val) {
                if (val.column) {
                    this.orderByColumn = val.prop
                    this.isAsc = val.order == 'ascending' ? 'ASC' : 'DESC'
                }
                this.init()
            }
        }
    })
</script>
</body>
</html>